<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Support\JsExp;
use LowCode\Traits\Slots\HasSlotAction;
use LowCode\Traits\Slots\HasSlotIcon;

/**
 * NPopconfirm
 * @method static static make(mixed $children = null) PopConfirm组件
 */
class PopConfirm extends Popover
{
    use HasSlotAction, HasSlotIcon;

    public function __construct(mixed $children = null)
    {
        parent::__construct();
        $this->componentName("NPopconfirm");
        $this->children($children);
    }

    /**
     * 是否显示图标
     * @param bool|JsExp $bool
     * @return $this
     */
    public function showIcon(bool|JsExp $bool = true): static
    {
        return $this->prop('showIcon', $bool);
    }

    /**
     * 取消按钮文字
     * @param string|JsExp $text
     * @return $this
     */
    public function negativeText(string|JsExp $text = "取消"): static
    {
        return $this->prop('negativeText', $text);
    }

    /**
     * 确定按钮文字
     * @param string|JsExp $text
     * @return $this
     */
    public function positiveText(string|JsExp $text = "确定"): static
    {
        return $this->prop('positiveText', $text);
    }

    /**
     * 取消按钮的属性
     * @param string|array $props
     * @return $this
     */
    public function negativeButtonProps(string|array $props = ""): static
    {
        return $this->prop('negativeButtonProps', $props);
    }

    /**
     * 确定按钮的属性
     * @param string|array $props
     * @return $this
     */
    public function positiveButtonProps(string|array $props = ""): static
    {
        return $this->prop('positiveButtonProps', $props);
    }


    /**
     *  点击确定的回调函数
     * @param string $event () => boolean | Promise<boolean> | any
     * @param string|null $id
     * @param array $modifiers
     * @return $this
     */
    public function onPositiveClick(string $event = "()=>{}", string $id = null, array $modifiers = []): static
    {
        return $this->event('onPositiveClick', jsFn($event, $id), $modifiers);
    }

    /**
     * 点击确定的回调函数
     * @param string $event () => boolean | Promise<boolean> | any
     * @param string|null $id
     * @param array $modifiers
     * @return $this
     */
    public function onNegativeClick(string $event = "()=>{ }", string $id = null, array $modifiers = []): static
    {
        return $this->event('onNegativeClick', jsFn($event, $id), $modifiers);
    }

}
